package com.zbkj.crmeb.enums;

import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.util.Objects;

/**
 * 功能描述: 套餐枚举
 * @Author: wangzh
 * @Date: 2023/4/24 17:12
 */
public enum RoleEnum {
    EXPERIENCE(1, "63", "体验版", BigDecimal.ZERO),

    BASIC(2, "64", "基础版", new BigDecimal("2800")),

    SPECIALITY(3, "65", "专业版", new BigDecimal("8800")),

    ENTERPRISE(4, "66", "企业版", new BigDecimal("17800")),
    ;
    private final Integer code;

    private final String role;

    private final String msg;

    private final BigDecimal price;

    RoleEnum(Integer code, String role, String msg, BigDecimal price) {
        this.code = code;
        this.role = role;
        this.msg = msg;
        this.price = price;
    }

    public Integer getCode() {
        return code;
    }

    public String getRole() {
        return role;
    }

    public String getMsg() {
        return msg;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public static RoleEnum getRoleByMsg(String msg) {
        for (RoleEnum value : values()) {
            if (StringUtils.equals(value.getMsg(), msg)) {
                return value;
            }
        }
        return EXPERIENCE;
    }

    public static RoleEnum getEnumByCode(Integer code) {
        for (RoleEnum value : values()) {
            if (Objects.equals(value.getCode(), code)) {
                return value;
            }
        }
        return EXPERIENCE;
    }

    public static RoleEnum getMsgByCode(Integer code) {
        for (RoleEnum value : values()) {
            if (Objects.equals(value.getCode(), code)) {
                return value;
            }
        }
        return EXPERIENCE;
    }
}
